using System.Collections.Generic;
using System.Text;
using Sedge.Core.Configuration;

namespace Sedge.Core.Execution.ReportElements
{
	public class ReportImageList : ReportElementBase
	{
		private readonly List<string> _images;

		public ReportImageList(Suite suite, List<string> images)
			: base(suite)
		{
			_images = images;
		}

		public ReportImageList(Suite suite, string path)
			: this(suite, new List<string> {path})
		{
		}

		public override void MergeWith(IReportElement element)
		{
			ReportImageList reportImageList = element as ReportImageList;
			if (reportImageList != null)
			{
				_images.AddRange(reportImageList._images);
			}
		}

		public override string GetHtml()
		{
			StringBuilder sb = new StringBuilder(GetHeaderAsHtml());
			sb.Append("<ul class=\"image-list\">");
			foreach (string image in _images)
			{
				sb.AppendFormat("<li><a href=\"{0}\"><img src=\"{0}\"></a></li>", image);
			}
			sb.Append("</ul>");

			return sb.ToString();
		}
	}
}